package com.starleague.battletech.unit.jpa.appengine;

import java.util.Map;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;

import com.starleague.battletech.unit.BattletechUnitEngineType;
import com.starleague.battletech.unit.IBattletechUnitEngine;
import com.starleague.battletech.unit.IWeight;

@MappedSuperclass
public abstract class BattletechUnitEngineGae
        extends BattletechUnitComponentGae
        implements IBattletechUnitEngine
{
    @Basic(optional = false)
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private BattletechUnitEngineType engineType;

    @Basic(optional = false)
    @Column(nullable = false)
    private int engineRating;

    protected BattletechUnitEngineGae(IWeight weight,
                                      BattletechUnitEngineType engineType,
                                      int engineRating)
    {
        super(weight);
        this.engineRating = engineRating;
        this.engineType = engineType;
    }

    protected BattletechUnitEngineGae()
    {
        //
    }

    @Override
    public boolean isHittable()
    {
        return true;
    }

    @Override
    public BattletechUnitEngineType getEngineType()
    {
        return this.engineType;
    }

    @Override
    public int getEngineRating()
    {
        return this.engineRating;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("engineType", this.engineType);
        infoPropertyMap.put("engineRating", this.engineRating);
        return infoPropertyMap;
    }
}
